.class public Lcom/opongo/android/custom/DealSearchActivity;
.super Lcom/opongo/android/custom/AbstractPostsListActivity;
.source "DealSearchActivity.java"


# static fields
.field public static final DEBUG:Z

.field private static final TAG:Ljava/lang/String;


# instance fields
.field private cat_parent:I


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 21
    sget-boolean v0, Lcom/opongo/blogapp/AbaSettings;->DEBUG:Z

    sput-boolean v0, Lcom/opongo/android/custom/DealSearchActivity;->DEBUG:Z

    .line 22
    const-class v0, Lcom/opongo/android/custom/DealSearchActivity;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/opongo/android/custom/DealSearchActivity;->TAG:Ljava/lang/String;

    .line 19
    return-void
.end method

.method public constructor <init>()V
    .locals 1

    .prologue
    .line 19
    invoke-direct {p0}, Lcom/opongo/android/custom/AbstractPostsListActivity;-><init>()V

    .line 23
    const/4 v0, -0x1

    iput v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->cat_parent:I

    .line 19
    return-void
.end method

.method private handleIntent(Landroid/content/Intent;)V
    .locals 3
    .parameter "intent"

    .prologue
    .line 67
    const-string v1, "android.intent.action.SEARCH"

    invoke-virtual {p1}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 68
    const-string v1, "query"

    invoke-virtual {p1, v1}, Landroid/content/Intent;->getStringExtra(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 69
    .local v0, query:Ljava/lang/String;
    sget-boolean v1, Lcom/opongo/android/custom/DealSearchActivity;->DEBUG:Z

    if-eqz v1, :cond_0

    sget-object v1, Lcom/opongo/android/custom/DealSearchActivity;->TAG:Ljava/lang/String;

    invoke-static {v1, v0}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 71
    :cond_0
    invoke-virtual {p0, v0}, Lcom/opongo/android/custom/DealSearchActivity;->doSearch(Ljava/lang/String;)V

    .line 73
    .end local v0           #query:Ljava/lang/String;
    :cond_1
    return-void
.end method


# virtual methods
.method protected doSearch(Ljava/lang/String;)V
    .locals 1
    .parameter "search"

    .prologue
    .line 76
    iput-object p1, p0, Lcom/opongo/android/custom/DealSearchActivity;->searchString:Ljava/lang/String;

    .line 77
    const/4 v0, 0x1

    invoke-virtual {p0, v0}, Lcom/opongo/android/custom/DealSearchActivity;->doRefresh(Z)V

    .line 78
    return-void
.end method

.method public onCreate(Landroid/os/Bundle;)V
    .locals 7
    .parameter "savedInstanceState"

    .prologue
    .line 28
    invoke-super {p0, p1}, Lcom/opongo/android/custom/AbstractPostsListActivity;->onCreate(Landroid/os/Bundle;)V

    .line 29
    const v0, 0x7f030014

    invoke-virtual {p0, v0}, Lcom/opongo/android/custom/DealSearchActivity;->setContentView(I)V

    .line 31
    sget-boolean v0, Lcom/opongo/android/custom/DealSearchActivity;->DEBUG:Z

    if-eqz v0, :cond_0

    .line 32
    sget-object v0, Lcom/opongo/android/custom/DealSearchActivity;->TAG:Ljava/lang/String;

    const-string v1, "*** create ***"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 34
    :cond_0
    new-instance v0, Lcom/opongo/blogapp/manager/DatabaseManager;

    .line 35
    const-string v1, "search_posts"

    const-string v2, "INSERT INTO search_posts (id,title,date,content,categories,commentscount,imageurl,post_order,guid,opened,newpost,did_vote,post_author,post_price,post_rating) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"

    invoke-direct {v0, p0, v1, v2}, Lcom/opongo/blogapp/manager/DatabaseManager;-><init>(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V

    .line 34
    iput-object v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    .line 37
    iget-object v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    const-string v1, "DELETE FROM search_posts"

    invoke-virtual {v0, v1}, Lcom/opongo/blogapp/manager/DatabaseManager;->execQuery(Ljava/lang/String;)V

    .line 39
    const-string v0, "SELECT * FROM search_posts ORDER BY date DESC"

    iput-object v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->query:Ljava/lang/String;

    .line 42
    const/4 v0, 0x0

    iput v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->blogType:I

    .line 44
    new-instance v0, Lcom/opongo/blogapp/manager/APIManager;

    invoke-direct {v0, p0}, Lcom/opongo/blogapp/manager/APIManager;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->apiManager:Lcom/opongo/blogapp/manager/APIManager;

    .line 47
    iget-object v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    iget-object v1, p0, Lcom/opongo/android/custom/DealSearchActivity;->query:Ljava/lang/String;

    invoke-virtual {v0, v1}, Lcom/opongo/blogapp/manager/DatabaseManager;->query(Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v4

    .line 48
    .local v4, cursor:Landroid/database/Cursor;
    invoke-virtual {p0, v4}, Lcom/opongo/android/custom/DealSearchActivity;->startManagingCursor(Landroid/database/Cursor;)V

    .line 50
    invoke-interface {v4}, Landroid/database/Cursor;->getCount()I

    move-result v0

    div-int/lit8 v0, v0, 0x14

    int-to-double v0, v0

    invoke-static {v0, v1}, Ljava/lang/Math;->ceil(D)D

    move-result-wide v0

    double-to-int v0, v0

    iput v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->postPage:I

    .line 52
    new-instance v0, Lcom/opongo/android/custom/PostListAdapter;

    const v3, 0x7f030018

    .line 53
    iget-object v1, p0, Lcom/opongo/android/custom/DealSearchActivity;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1}, Lcom/opongo/blogapp/manager/DatabaseManager;->getTableName()Ljava/lang/String;

    move-result-object v5

    iget-object v6, p0, Lcom/opongo/android/custom/DealSearchActivity;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    move-object v1, p0

    move-object v2, p0

    invoke-direct/range {v0 .. v6}, Lcom/opongo/android/custom/PostListAdapter;-><init>(Landroid/app/Activity;Landroid/content/Context;ILandroid/database/Cursor;Ljava/lang/String;Lcom/opongo/blogapp/manager/DatabaseManager;)V

    .line 52
    iput-object v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->mAdapter:Lcom/opongo/android/custom/PostListAdapter;

    .line 55
    iget-object v0, p0, Lcom/opongo/android/custom/DealSearchActivity;->mAdapter:Lcom/opongo/android/custom/PostListAdapter;

    invoke-virtual {p0, v0}, Lcom/opongo/android/custom/DealSearchActivity;->setListAdapter(Landroid/widget/ListAdapter;)V

    .line 57
    invoke-virtual {p0}, Lcom/opongo/android/custom/DealSearchActivity;->getIntent()Landroid/content/Intent;

    move-result-object v0

    invoke-direct {p0, v0}, Lcom/opongo/android/custom/DealSearchActivity;->handleIntent(Landroid/content/Intent;)V

    .line 58
    return-void
.end method

.method protected onNewIntent(Landroid/content/Intent;)V
    .locals 0
    .parameter "intent"

    .prologue
    .line 62
    invoke-virtual {p0, p1}, Lcom/opongo/android/custom/DealSearchActivity;->setIntent(Landroid/content/Intent;)V

    .line 63
    invoke-direct {p0, p1}, Lcom/opongo/android/custom/DealSearchActivity;->handleIntent(Landroid/content/Intent;)V

    .line 64
    return-void
.end method
